const snrLog = {
  state: {
    snrLog: [],
    snrLogCount: 0
  },
  mutations: {
    setsnrLog (state, data) {
      state.snrLog = data
    },
    setsnrLogCount (state, data) {
      state.snrLogCount = data
    }
  },
  actions: {
    async getSnrLogList (context, payload) {
      let response = await context.dispatch('axios', {
        method: 'get',
        url: '/api/abs/mtw/snr/',
        params: {
          page: payload.page,
          page_size: payload.page_size,

          begin: payload.begin,
          end: payload.end,
          device: payload.device
        }
      })
      context.commit('setsnrLog', response.data.results)
      context.commit('setsnrLogCount', response.data.count)
    }
  },
  getters: {
    getSnrLogList: (state) => {
      return state.snrLog.map(item => {
        return {
          ...item,
          snr1: item.snr1,
          snr2: item.snr2,
          dateTime: item.time.split('.')[0].split('T').join(' ')
        }
      })
    }
  }
}
export default snrLog
